package reflect;

import reflect.annotations.AutoRunClass;

import java.lang.reflect.Field;

/*反射的暴力机制
 */
@AutoRunClass
public class ReflectDemo09 {
    public static void main(String[] args) throws Exception{
        String s1 = "abc";
        System.out.println("s1:"+s1);//abc

        Class cla = String.class;
        Field field = cla.getDeclaredField("value");
        field.setAccessible(true);
        field.set(s1, new char[]{'h','e','l','l','o'});
        System.out.println("s1:"+s1);

        String s2 = "abc";
        System.out.println("s2:" + s2);//hello
        String s3 = "abc";
        System.out.println("s3:" + s3);//hello
    }
}
